package com.webchat.rmi.pgc;

import com.webchat.common.bean.APIPageResponseBean;
import com.webchat.common.bean.APIResponseBean;
import com.webchat.domain.vo.request.publicaccount.SaveArticleRequestVO;
import com.webchat.domain.vo.response.publicaccount.ArticleBaseResponseVO;
import com.webchat.rmi.interceptor.RpcRequestInterceptor;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Map;


@FeignClient(name = "webchat-pgc-service",
        contextId = "officialArticleClient",
        configuration = RpcRequestInterceptor.class)
public interface OfficialArticleClient {

    /**
     * 公众号推文
     *
     * @param saveArticleRequest
     * @return
     */
    @PostMapping("/pgc-service/official/article/submit")
    APIResponseBean<Long> submit(@RequestBody SaveArticleRequestVO saveArticleRequest);

    /**
     * 获取公众号文章详情
     *
     * @param id
     * @return
     */
    @GetMapping("/pgc-service/official/article/detail/{id}")
    APIResponseBean<ArticleBaseResponseVO> detail(@PathVariable Long id,
                                                  @RequestParam(name = "isNeedContent", required = false,
                                                          defaultValue = "false") Boolean isNeedContent);

    /**
     * 查询文章列表
     *
     * @param pageNo
     * @param pageSize
     * @return
     */
    @GetMapping("/pgc-service/official/article/page")
    APIResponseBean<APIPageResponseBean<ArticleBaseResponseVO>> page(
            @RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo,
            @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize);

    /**
     * 批量查询redis，获取文章详情缓存
     *
     * 场景：公众号详情页，一次可能查询10篇文章
     * @param articleIds
     * @return
     */
    @GetMapping("/pgc-service/official/article/batchGet")
    APIResponseBean<Map<Long, ArticleBaseResponseVO>> batchGet(@RequestBody List<Long> articleIds);
}
